<?php
/* @var $this ProductController */
/* @var $model Product*/
$this->breadcrumbs = array(
   'Quản lý sản phẩm' => '/admin/'.$this->id,
   'Thêm sách'
);
Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/backend/js/jquery.tokeninput.js');
Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl.'/backend/css/token-input-facebook.css');
?>
<div class="form" id="<?php echo Yii::app()->controller->id . '-' . Yii::app()->controller->action->id?>">
<?php
   $form = $this->beginWidget('CActiveForm',array(
      'enableClientValidation' => true,
      'clientOptions'=>array(
   		'validateOnSubmit'=>true,
   	),
      'htmlOptions' => array(
         'class' => 'form-horizontal',
         'enctype' => 'multipart/form-data',
      ),
      'id' => Yii::app()->controller->id . '_' . Yii::app()->controller->action->id )
   );
?>
   <p class="note">Những dòng đánh dấu <span class="required">*</span> là bắt buộc.</p>

	<?php echo $form->errorSummary($model,'Kiểm tra lại các giá trị bạn vừa nhập vào'); 
      if($message != ''){
         echo CHtml::tag('div', array('class'=>'message-success'),$message);
      }
   ?>
   <input name="session_user" type="hidden" value="<?php echo $session_user?>"/>
   <input name="action_user" type="hidden" value="" id="action_user" />
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_name',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'book_name',array('style' => 'width:400px;'));?>
      </div>
   </div>
   
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_num_page',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'book_num_page');?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_price',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'book_price');?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_sale',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'book_sale');?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_date_publish',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'book_date_publish',array('class' => 'datepicker'));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_cat_id',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->dropDownList($model, 'book_cat_id',$tree_cate);?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_pub_id',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->dropDownList($model, 'book_pub_id',$list_publisher);?>
      </div>
   </div>
   <div class="control-group">
      <?php echo CHtml::label('Tên tác giả','aut_id',array(
         'class' => 'control-label'
      ));?>
      <div class="controls">
         <?php echo CHtml::telField('aut_id','',array(
            'id' => 'aut_id'
         ))?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_content',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textArea($model, 'book_content',array(
            'class' => 'redactor',
         ));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model,'book_image',array('class' => 'control-label')); ?>
      <div class="controls">
      <?php echo $form->fileField($model, 'book_image')?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_special',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->checkBox($model, 'book_special');?>
      </div>
   </div>
   
   <div class="control-group">
      <?php echo $form->labelEx($model, 'book_active',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->checkBox($model, 'book_active',array('checked' => 'checked'));?>
      </div>
   </div>
   <div class="form-actions">
      <?php if($model->isNewRecord)
               echo CHtml::submitButton('Thêm mới',array('class' => 'btn btn-info'));
            else
               echo CHtml::submitButton('Lưu',array('class' => 'btn btn-info'));
      ?>
      <?php echo CHtml::resetButton('Làm lại',array('class' => 'btn btn-warning'))?>
	</div>
<?php $this->endWidget(); ?>
</div>
<script>
   $(document).ready(function(){
      
   });
   
</script>
<script>
   $(document).ready(function(){
      $(".redactor").redactor({
         lang: 'vi',
         imageUpload: '<?php echo Yii::app()->request->hostInfo;?>/redactor/scripts/image_upload.php',
         plugins: ['fontsize']
      });
      $(".datepicker").datepicker({
         dateFormat:"dd/mm/yy",
      });
      $("#aut_id").tokenInput("/admin/product/AjaxTokenInputAuthor", {
         theme: "facebook",
         hintText:"Gõ tên tác giả",
         noResultsText:"Không tìm thấy",
         searchingText:"Đang tìm...",
         preventDuplicates: true,
         <?php if(count($list_author) > 0){
            //echo json_encode($list_author);
            ?>
            prePopulate:<?php echo json_encode($list_author)?>,   
         <?php }?>
      });
   });
</script>